-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branch/Switch for virtual function calls #45
base: master
Are you sure you want to change the base?
Conversation
…ched by indirect function calls (CUDA) or direct callables (Optix) but converted into switch-like statements
…table rather than a series of individual branches.
…a binary search to branch to the appropriate vcall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
bool jump_table = jit_flag(JitFlag::VCallBranchJumpTable); | ||
bool binary_search = jit_flag(JitFlag::VCallBranchBinarySearch); | ||
|
||
if (jump_table == binary_search) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am intrigued by this condition. I suppose this could also be written as !jump_table && !binary_search
? In the case where both are true we should throw an error no?
if (jump_table) | ||
jitc_log(Warn, "jitc_var_vcall_assemble_cuda(): both " | ||
"JitFlag::VCallBranchJumpTable and " | ||
"JitFlag::VCallBranchBinarySearch are enabled, " | ||
"defaulting back to linear search!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this now. Maybe we should throw an exception instead?
8930bc9
to
91201ef
Compare
6caa418
to
1cb66e8
Compare
This PR adds different strategies to handle virtual function calls.
Currently, in order to do a virtual function call in CUDA, we use indirect function calls to call either an OptiX direct callable or a CUDA function. Given that we know exactly the set of possible targets for any virtual function call, it is not necessary to have the indirection and we can explicitly call the appropriate target function.
This PR adds a new
JitFlag
, calledVCallBranch
which will replace the indirect function call by a series of branches to call the appropriate target function. There are three different branching strategies implemented:VCallBranch
.VCallBranchBinarySearch
JIT flag.VCallBranchJumpTable
JIT flag